Skip to content

Conversation

@bconti123
Copy link
Member

@bconti123 bconti123 commented Oct 20, 2025

Fixes #1724

What changes did you make and why did you make them ?

Screenshots of Proposed Changes Of The Website (if any, please do not screen shot code changes)

Visuals before changes are applied ModalsBefore
Visuals after changes are applied ModalsAfter

@eunicode eunicode requested a review from Copilot November 11, 2025 22:51
@eunicode eunicode requested review from eunicode and removed request for Copilot November 11, 2025 22:52
Copilot finished reviewing on behalf of eunicode November 11, 2025 22:53
@eunicode eunicode requested a review from Copilot November 11, 2025 22:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR converts the existing modal implementation to use Material-UI's Modal component with proper open/close behavior. The changes enable users to close the modal via the Escape key, Close button, or by clicking outside the modal box.

Key Changes:

  • Replaced the basic <div> modal structure with MUI's Modal and Box components
  • Added state management for modal open/close behavior using useEffect and useState
  • Integrated handleClose function to properly clean up state when the modal is closed

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot finished reviewing on behalf of eunicode November 11, 2025 22:55
@bconti123
Copy link
Member Author

Thank you for the review! I've made the updates and resolved the conversation.

@bkmorgan3
Copy link
Member

@bconti123 approved, good to merge

Copy link
Member

@eunicode eunicode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thanks for your patience while I reviewed this.

Question (non-blocking): Was there a reason you removed ARIA attributes?

Suggestion (non-blocking): You can simplify this component by removing both the useEffect and the open state. Currently, the open state syncs with the selectedEvent state, so we’re maintaining two states that represent the same piece of information. Instead of duplicating state, we can derive it. useEffect is also not necessary, because React will automatically re-render when selectedEvent changes.

Current approach:

const [open, setOpen] = useState(false);

useEffect(() => {
  if (selectedEvent) { setOpen(true); }
  else { setOpen(false); }
}, [selectedEvent]);

Suggested approach (derived state):

const open = Boolean(selectedEvent);

open is now derived from selectedEvent and the useEffect can be removed entirely.

Your modal would stay the same:

<Modal open={open} onClose={handleClose}>

To close it, you only need to reset selectedEvent, so handleClose() would just be:

function handleClose() {
  setFormErrors(null);
  setSelectedEvent(null);
}

When selectedEvent becomes null, the component re-renders, open becomes false, and the modal closes. This avoids duplicated state and follows React best practices around deriving state instead of duplicating state.

@bconti123
Copy link
Member Author

@eunicode Thank you for your feedback. I like the suggested approach. This makes sense. You are right that the open state and the useEffect were duplicating the same information from selectedEvent, and I updated the code to look cleaner.

Regarding your question about the ARIA attributes, yes, there was a reason in the reviewed changes, and that conversation is now resolved. I did not find any IDs that matched the ARIA attributes, so I resolved the thread.

I will merge this now.

@bconti123 bconti123 merged commit 68b73b9 into hackforla:development Nov 25, 2025
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change Edit Meeting Times base component to an MUI modal

3 participants